﻿<UserControl xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:help="clr-namespace:TelecoSystems.Infrastructure.Helpers;assembly=TelecoSystems.Infrastructure"
    xmlns:cmd="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
    xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" 
    xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:pm="clr-namespace:TelecoSystems.Web.Models.PresentationModel" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:custCtx="clr-namespace:TelecoSystems.Web.Services.Customers" xmlns:model="clr-namespace:TelecoSystems.Web.Models" xmlns:prodCtx="clr-namespace:TelecoSystems.Web.Services.Products" xmlns:varCtx="clr-namespace:TelecoSystems.Web.Services.Variants" xmlns:System="clr-namespace:System;assembly=mscorlib"  x:Class="TelecoSystems.Modules.Contracts.Views.ContractsBrowseView" 
    mc:Ignorable="d"
    d:DesignHeight="800" d:DesignWidth="1000">
    <UserControl.Resources>
        <ResourceDictionary>
            <DataTemplate x:Key="ContractsDataTemplate">
                <Grid Height="42">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="14" />
                        <RowDefinition Height="28" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Customer" Grid.Row="0" Grid.Column="0" />
                    <TextBlock Text="Dealer" Grid.Row="0" Grid.Column="1" />
                    <TextBlock Text="Product/Variant" Grid.Row="0" Grid.Column="2" />
                    <TextBlock Text="{Binding CustomerName, Mode=OneWay}" Margin="10,0" TextWrapping="Wrap" Grid.Row="1" Grid.Column="0"/>
                    <TextBlock Text="{Binding DealerName, Mode=OneWay}" Margin="10,0" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" />
                    <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="2">
                    <TextBlock Text="{Binding ProductName, Mode=OneWay}" TextWrapping="Wrap"/>
                    <TextBlock Text="{Binding VariantName, Mode=OneWay}" TextWrapping="Wrap"/>
                    <TextBlock Text="{Binding Price, Mode=OneWay}" TextWrapping="Wrap"/>
                    </StackPanel>                    
                </Grid>
            </DataTemplate>
            <DataTemplate x:Key="CustomerAutoCompleteDataTemplate">
                <Grid Margin="5">
                    <TextBlock Margin="0" Text="{Binding Name, Mode=OneWay}" TextWrapping="Wrap"/>
                </Grid>
            </DataTemplate>
        	<ControlTemplate x:Key="ValidationToolTipTemplate">
        		<Grid x:Name="Root" Margin="5,0" Opacity="0" RenderTransformOrigin="0,0">
        			<Grid.RenderTransform>
        				<TranslateTransform x:Name="xform" X="-25"/>
        			</Grid.RenderTransform>
        			<VisualStateManager.VisualStateGroups>
        				<VisualStateGroup x:Name="OpenStates">
        					<VisualStateGroup.Transitions>
        						<VisualTransition GeneratedDuration="0"/>
        						<VisualTransition GeneratedDuration="0:0:0.2" To="Open">
        							<Storyboard>
        								<DoubleAnimation Duration="0:0:0.2" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform">
        									<DoubleAnimation.EasingFunction>
        										<BackEase Amplitude=".3" EasingMode="EaseOut"/>
        									</DoubleAnimation.EasingFunction>
        								</DoubleAnimation>
        								<DoubleAnimation Duration="0:0:0.2" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
        							</Storyboard>
        						</VisualTransition>
        					</VisualStateGroup.Transitions>
        					<VisualState x:Name="Closed">
        						<Storyboard>
        							<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
        						</Storyboard>
        					</VisualState>
        					<VisualState x:Name="Open">
        						<Storyboard>
        							<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform"/>
        							<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
        						</Storyboard>
        					</VisualState>
        				</VisualStateGroup>
        			</VisualStateManager.VisualStateGroups>
        			<Border Background="#052A2E31" CornerRadius="5" Margin="4,4,-4,-4"/>
        			<Border Background="#152A2E31" CornerRadius="4" Margin="3,3,-3,-3"/>
        			<Border Background="#252A2E31" CornerRadius="3" Margin="2,2,-2,-2"/>
        			<Border Background="#352A2E31" CornerRadius="2" Margin="1,1,-1,-1"/>
        			<Border Background="#FFDC000C" CornerRadius="2"/>
        			<Border CornerRadius="2">
        				<TextBlock Foreground="White" MaxWidth="250" Margin="8,4,8,4" TextWrapping="Wrap" Text="{Binding (Validation.Errors)[0].ErrorContent}" UseLayoutRounding="false"/>
        			</Border>
        		</Grid>
        	</ControlTemplate>
        	<Style x:Key="ListBoxStyleWithStates" TargetType="ListBox">
        		<Setter Property="Padding" Value="1"/>
        		<Setter Property="Background" Value="#FFFFFFFF"/>
        		<Setter Property="Foreground" Value="#FF000000"/>
        		<Setter Property="HorizontalContentAlignment" Value="Left"/>
        		<Setter Property="VerticalContentAlignment" Value="Top"/>
        		<Setter Property="IsTabStop" Value="False"/>
        		<Setter Property="BorderThickness" Value="1"/>
        		<Setter Property="TabNavigation" Value="Once"/>
        		<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        		<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        		<Setter Property="BorderBrush">
        			<Setter.Value>
        				<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
        					<GradientStop Color="#FFA3AEB9" Offset="0"/>
        					<GradientStop Color="#FF8399A9" Offset="0.375"/>
        					<GradientStop Color="#FF718597" Offset="0.375"/>
        					<GradientStop Color="#FF617584" Offset="1"/>
        				</LinearGradientBrush>
        			</Setter.Value>
        		</Setter>
        		<Setter Property="Template">
        			<Setter.Value>
        				<ControlTemplate TargetType="ListBox">
        					<Grid>
        						<VisualStateManager.VisualStateGroups>
        							<VisualStateGroup x:Name="ValidationStates">
        								<VisualStateGroup.Transitions>
        									<VisualTransition GeneratedDuration="0:0:1">
        										<VisualTransition.GeneratedEasingFunction>
        											<CircleEase EasingMode="EaseOut"/>
        										</VisualTransition.GeneratedEasingFunction>
        									</VisualTransition>
        								</VisualStateGroup.Transitions>
        								<VisualState x:Name="Valid"/>
        								<VisualState x:Name="InvalidUnfocused">
        									<Storyboard>
        										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ValidationErrorElement">
        											<DiscreteObjectKeyFrame KeyTime="0">
        												<DiscreteObjectKeyFrame.Value>
        													<Visibility>Visible</Visibility>
        												</DiscreteObjectKeyFrame.Value>
        											</DiscreteObjectKeyFrame>
        										</ObjectAnimationUsingKeyFrames>
        									</Storyboard>
        								</VisualState>
        								<VisualState x:Name="InvalidFocused">
        									<Storyboard>
        										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ValidationErrorElement">
        											<DiscreteObjectKeyFrame KeyTime="0">
        												<DiscreteObjectKeyFrame.Value>
        													<Visibility>Visible</Visibility>
        												</DiscreteObjectKeyFrame.Value>
        											</DiscreteObjectKeyFrame>
        										</ObjectAnimationUsingKeyFrames>
        										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="validationTooltip">
        											<DiscreteObjectKeyFrame KeyTime="0">
        												<DiscreteObjectKeyFrame.Value>
        													<System:Boolean>True</System:Boolean>
        												</DiscreteObjectKeyFrame.Value>
        											</DiscreteObjectKeyFrame>
        										</ObjectAnimationUsingKeyFrames>
        									</Storyboard>
        								</VisualState>
        							</VisualStateGroup>
        						</VisualStateManager.VisualStateGroups>
        						<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
        							<ScrollViewer x:Name="ScrollViewer" BorderBrush="Transparent" BorderThickness="0" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" TabNavigation="{TemplateBinding TabNavigation}">
        								<ItemsPresenter/>
        							</ScrollViewer>
        						</Border>
        						<Border x:Name="ValidationErrorElement" BorderBrush="#FFDB000C" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" Visibility="Collapsed">
        							<ToolTipService.ToolTip>
        								<ToolTip x:Name="validationTooltip" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Template="{StaticResource ValidationToolTipTemplate}">
        									<ToolTip.Triggers>
        										<EventTrigger RoutedEvent="Canvas.Loaded">
        											<BeginStoryboard>
        												<Storyboard>
        													<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsHitTestVisible" Storyboard.TargetName="validationTooltip">
        														<DiscreteObjectKeyFrame KeyTime="0">
        															<DiscreteObjectKeyFrame.Value>
        																<System:Boolean>true</System:Boolean>
        															</DiscreteObjectKeyFrame.Value>
        														</DiscreteObjectKeyFrame>
        													</ObjectAnimationUsingKeyFrames>
        												</Storyboard>
        											</BeginStoryboard>
        										</EventTrigger>
        									</ToolTip.Triggers>
        								</ToolTip>
        							</ToolTipService.ToolTip>
        							<Grid Background="Transparent" HorizontalAlignment="Right" Height="10" Margin="0,-4,-4,0" VerticalAlignment="Top" Width="10">
        								<Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" Fill="#FFDC000C" Margin="-1,3,0,0"/>
        								<Path Data="M 0,0 L2,0 L 8,6 L8,8" Fill="#ffffff" Margin="-1,3,0,0"/>
        							</Grid>
        						</Border>
        					</Grid>
        				</ControlTemplate>
        			</Setter.Value>
        		</Setter>
        	</Style>
        	<Style x:Key="ListBoxItemStyleWithStyles" TargetType="ListBoxItem">
        		<Setter Property="Padding" Value="15,5,5,5"/>
        		<Setter Property="HorizontalContentAlignment" Value="Left"/>
        		<Setter Property="VerticalContentAlignment" Value="Top"/>
        		<Setter Property="Background" Value="Transparent"/>
        		<Setter Property="BorderThickness" Value="1"/>
        		<Setter Property="TabNavigation" Value="Local"/>
        		<Setter Property="Template">
        			<Setter.Value>
        				<ControlTemplate TargetType="ListBoxItem">
        					<Grid x:Name="grid" Background="{TemplateBinding Background}" RenderTransformOrigin="0.5,0.5">
        						<Grid.Projection>
        							<PlaneProjection/>
        						</Grid.Projection>
        						<Grid.RenderTransform>
        							<CompositeTransform/>
        						</Grid.RenderTransform>
        						<VisualStateManager.VisualStateGroups>
        							<VisualStateGroup x:Name="CommonStates">
        								<VisualStateGroup.Transitions>
        									<VisualTransition GeneratedDuration="0:0:0.2">
        										<VisualTransition.GeneratedEasingFunction>
        											<CircleEase EasingMode="EaseIn"/>
        										</VisualTransition.GeneratedEasingFunction>
        									</VisualTransition>
        								</VisualStateGroup.Transitions>
        								<VisualState x:Name="Normal"/>
        								<VisualState x:Name="MouseOver">
        									<Storyboard>
        										<DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor"/>
        										<DoubleAnimation Duration="0" To="1.05" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
        										<DoubleAnimation Duration="0" To="1.05" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
        										<!--<DoubleAnimation Duration="0" To="-10" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
        										<DoubleAnimation Duration="0" To="10" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
        										<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationZ)" Storyboard.TargetName="grid" d:IsOptimized="True"/>-->
        									</Storyboard>
        								</VisualState>
        								<VisualState x:Name="Disabled">
        									<Storyboard>
        										<DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="contentPresenter"/>
        									</Storyboard>
        								</VisualState>
        							</VisualStateGroup>
        							<VisualStateGroup x:Name="SelectionStates">
        								<VisualStateGroup.Transitions>
        									<VisualTransition GeneratedDuration="0:0:0.5">
        										<VisualTransition.GeneratedEasingFunction>
        											<CircleEase EasingMode="EaseIn"/>
        										</VisualTransition.GeneratedEasingFunction>
        									</VisualTransition>
        								</VisualStateGroup.Transitions>
        								<VisualState x:Name="Unselected"/>
        								<VisualState x:Name="Selected">
        									<Storyboard>
        										<DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor2"/>
                                                <DoubleAnimation Duration="0" To="-10" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
                                                <DoubleAnimation Duration="0" To="10" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
                                            </Storyboard>
        								</VisualState>
        							</VisualStateGroup>
        							<VisualStateGroup x:Name="FocusStates">
        								<VisualState x:Name="Focused">
        									<Storyboard>
        										<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="FocusVisualElement">
        											<DiscreteObjectKeyFrame KeyTime="0">
        												<DiscreteObjectKeyFrame.Value>
        													<Visibility>Visible</Visibility>
        												</DiscreteObjectKeyFrame.Value>
        											</DiscreteObjectKeyFrame>
        										</ObjectAnimationUsingKeyFrames>
        									</Storyboard>
        								</VisualState>
        								<VisualState x:Name="Unfocused"/>
        							</VisualStateGroup>
        						</VisualStateManager.VisualStateGroups>
        						<Rectangle x:Name="fillColor" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
        						<Rectangle x:Name="fillColor2" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
        						<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RenderTransformOrigin="0.5,0.5">
        							<ContentPresenter.RenderTransform>
        								<CompositeTransform/>
        							</ContentPresenter.RenderTransform>
        							<ContentPresenter.Projection>
        								<PlaneProjection/>
        							</ContentPresenter.Projection>
        						</ContentPresenter>
        						<Rectangle x:Name="FocusVisualElement" RadiusY="1" RadiusX="1" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed"/>
        					</Grid>
        				</ControlTemplate>
        			</Setter.Value>
        		</Setter>
        	</Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <controlsToolkit:BusyIndicator x:Name="ModuleBusyIndicator" BusyContent="{Binding BusyContent}" IsBusy="{Binding IsBusy}" Foreground="Black" DisplayAfter="0:0:0.0" FontSize="11" OverlayStyle="{StaticResource ActivityOverlayStyle}" RenderTransformOrigin="0.5,0.5">
        <Grid x:Name="LayoutRoot">
            <Grid.RowDefinitions>
                <RowDefinition Height="40" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="620" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ListBox Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Margin="10" HorizontalAlignment="Left" ItemsSource="{Binding Contracts, Mode=OneWay}" SelectedItem="{Binding ContractDetail, Mode=TwoWay}" x:Name="contractPMListBox" ItemTemplate="{StaticResource ContractsDataTemplate}" VerticalAlignment="Stretch" Width="600" Style="{StaticResource ListBoxStyleWithStates}" ItemContainerStyle="{StaticResource ListBoxItemStyleWithStyles}">
                <ListBox.Effect>
                    <DropShadowEffect />
                </ListBox.Effect>
            </ListBox>
            <StackPanel Grid.Row="0" Grid.Column="1" Margin="20,5" Orientation="Horizontal">
                <Button Content="Add" Width="60" Margin="5,0" Height="24" cmd:Click.Command="{Binding AddContractCommand}" />
                <Button Content="Delete" Width="80" Margin="5,0" Height="24" cmd:Click.Command="{Binding DeleteContractCommand}" />
            </StackPanel>
            <Border Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Margin="20,10" VerticalAlignment="Top" Background="WhiteSmoke" CornerRadius="6" Width="280" Padding="10">
                <Border.Effect>
                    <DropShadowEffect />
                </Border.Effect>
                <Grid DataContext="{Binding Path=SelectedItem, ElementName=contractPMListBox, Mode=TwoWay}" x:Name="Detail">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <sdk:Label Content="Customer:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <ComboBox DisplayMemberPath="Name" SelectedValuePath="Id" SelectedValue="{Binding CustomerId, Mode=TwoWay}" Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" ItemsSource="{Binding Data, ElementName=CustomerDomainDataSource}" Margin="3" x:Name="customerNameComboBox" VerticalAlignment="Center" Width="120">
                        <ComboBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VirtualizingStackPanel />
                            </ItemsPanelTemplate>
                        </ComboBox.ItemsPanel>
                    </ComboBox>

                    <!--<sdk:AutoCompleteBox ItemsSource="{Binding ElementName=CustomerDomainDataSource, Path=Data}" Grid.Row="2" Grid.Column="1" ValueMemberBinding="{Binding Path=CustomerName, Mode=TwoWay}" FilterMode="Contains" ValueMemberPath="Name" ItemTemplate="{StaticResource CustomerAutoCompleteDataTemplate}">
                </sdk:AutoCompleteBox>-->
                    <sdk:Label Content="Dealer Name:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBlock Grid.Column="1" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="3" x:Name="dealerNameTextBlock" Text="{Binding DealerName, Mode=OneWay}" VerticalAlignment="Center" />
                    <sdk:Label Content="Price:" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBlock Grid.Column="1" Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="3" x:Name="priceTextBlock" Text="{Binding SelectedItem.Price, ElementName=variantNameComboBox, Mode=TwoWay}" VerticalAlignment="Center" />
                    <sdk:Label Content="Product:" Grid.Column="0" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <ComboBox DisplayMemberPath="Name" SelectionChanged="productNameComboBox_SelectionChanged" SelectedValuePath="Id" SelectedValue="{Binding ProductId, Mode=TwoWay}" Grid.Column="1" Grid.Row="5" Height="23" HorizontalAlignment="Left" ItemsSource="{Binding Data, ElementName=ProductDomainDataSource}" Margin="3" x:Name="productNameComboBox" VerticalAlignment="Center" Width="120">
                        <ComboBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VirtualizingStackPanel />
                            </ItemsPanelTemplate>
                        </ComboBox.ItemsPanel>
                    </ComboBox>
                    <sdk:Label Content="Variant:" Grid.Column="0" Grid.Row="6" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <ComboBox DisplayMemberPath="Name" Grid.Column="1" Grid.Row="6" Height="23" HorizontalAlignment="Left" SelectedValuePath="Id" SelectedValue="{Binding VariantId, Mode=TwoWay}" ItemsSource="{Binding Data, ElementName=VariantDomainDataSource}" Margin="3" x:Name="variantNameComboBox" VerticalAlignment="Center" Width="120">
                        <ComboBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VirtualizingStackPanel />
                            </ItemsPanelTemplate>
                        </ComboBox.ItemsPanel>
                    </ComboBox>
                    <StackPanel Grid.Row="7" Grid.ColumnSpan="2" Orientation="Horizontal">
                        <Button Content="Submit" Height="24" Margin="5" cmd:Click.Command="{Binding DataContext.SubmitChangesCommand, ElementName=LayoutRoot}" Width="100" />
                        <Button Content="Cancel" Height="24" Margin="5" cmd:Click.Command="{Binding DataContext.CancelCommand, ElementName=LayoutRoot}" Width="80" />
                    </StackPanel>
                </Grid>
            </Border>
            <riaControls:DomainDataSource AutoLoad="True" Height="0" LoadedData="productDomainDataSource_LoadedData" x:Name="ProductDomainDataSource" QueryName="GetProducsQuery" Width="0">
                <riaControls:DomainDataSource.DomainContext>
                    <prodCtx:ProductsDomainContext />
                </riaControls:DomainDataSource.DomainContext>
                <riaControls:DomainDataSource.SortDescriptors>
                    <riaControls:SortDescriptor Direction="Ascending" PropertyPath="Name"/>
                </riaControls:DomainDataSource.SortDescriptors>
            </riaControls:DomainDataSource>
            <riaControls:DomainDataSource AutoLoad="True" Height="0" LoadedData="customerDomainDataSource_LoadedData" x:Name="CustomerDomainDataSource" QueryName="GetCustomersQuery" Width="0">
                <riaControls:DomainDataSource.DomainContext>
                    <custCtx:CustomersDomainContext />
                </riaControls:DomainDataSource.DomainContext>
                <riaControls:DomainDataSource.SortDescriptors>
                    <riaControls:SortDescriptor Direction="Ascending" PropertyPath="Name"/>
                </riaControls:DomainDataSource.SortDescriptors>
            </riaControls:DomainDataSource>
            <riaControls:DomainDataSource LoadingData="VariantDomainDataSource_LoadingData" AutoLoad="False" Height="0" LoadedData="variantDomainDataSource_LoadedData" x:Name="VariantDomainDataSource" QueryName="GetVariantsForProductQuery" Width="0">
                <riaControls:DomainDataSource.QueryParameters>
                    <riaControls:Parameter ParameterName="productId" Value="{Binding SelectedItem.Id, ElementName=productNameComboBox, Mode=OneWay}" />
                </riaControls:DomainDataSource.QueryParameters>
                <riaControls:DomainDataSource.SortDescriptors>
                    <riaControls:SortDescriptor Direction="Ascending" PropertyPath="Name"/>
                </riaControls:DomainDataSource.SortDescriptors>
                <riaControls:DomainDataSource.DomainContext>
                    <varCtx:VariantsDomainContext />
                </riaControls:DomainDataSource.DomainContext>
            </riaControls:DomainDataSource>

        </Grid>
    </controlsToolkit:BusyIndicator>
</UserControl>
